package com.yao2san.dbdif.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseData<T> implements Serializable {
    private int code;
    private T data;
    private String msg;

    private  ResponseData(int status,String msg,T data) {
        this.code = status;
        this.msg = msg;
        this.data = data;
    }
    private  ResponseData(int status,String msg) {
        this.code = status;
        this.msg = msg;
    }
    public static <T>ResponseData<T> success(T data){
        return new ResponseData<T>(ResponseCode.SUCCESS.getCode(),"",data);
    }
    public static <T>ResponseData<T> success(T data,String msg){
        return new ResponseData<T>(ResponseCode.SUCCESS.getCode(),msg,data);
    }
    public static <T>ResponseData<T> error(){
        return new ResponseData<T>(ResponseCode.ERROR.getCode(),"");
    }
    public static <T>ResponseData<T> error(String msg){
        return new ResponseData<T>(ResponseCode.ERROR.getCode(),msg);
    }
    public static <T>ResponseData<T> error(int status,String msg){
        return new ResponseData<T>(status,msg);
    }
}
